home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17185 < prev    next >
Encoding:
Text File  |  1996-08-05  |  947 b   |  31 lines

  1. Newsgroups: comp.lang.c,comp.lang.c++
  2. Path: news.inap.net!news1!ind-008-237-87
  3. From: dlmiller@iquest.net (Doug Miller)
  4. Subject: Re: Q:Hex to Decimal?
  5. X-Nntp-Posting-Host: ind-008-237-87.iquest.net
  6. Message-ID: <Dpr4w6.5M0@iquest.net>
  7. Sender: news@iquest.net (News Admin)
  8. Organization: IQuest Network Services
  9. X-Newsreader: News Xpress Version 1.0 Beta #2.1
  10. References: <316D2289.4759@tricon.net>
  11. Date: Fri, 12 Apr 1996 13:48:05 GMT
  12.  
  13. Thomas A Cooper <tacooper@tricon.net> wrote:
  14. >I saw in a magazine a simple function to convert a HEX string to an
  15. >integer:
  16. >
  17. >long int FAR PASCAL hex2int(char far *s)
  18. >{
  19. >     return strtol(s,NULL,16);
  20. >}
  21. >
  22. > I'm struggling with the reverse situation, a function to convert an
  23. >integer into a HEX string. Anybody got any ideas?? Thanks in advance for
  24. >your help.
  25. >                              Tom Cooper
  26. >                              tacooper@tricon.net
  27.  
  28. use sprintf(), e.g.
  29.  
  30. sprintf (hexstring, "%x", integer);
  31.